/**
 * 用户书籍管理
 * @project readnote
 * @author huxh
 * @date 2012-5-15
 **/
package com.readnote.admin.book;

import com.cr.backbone.action.AppBaseActionSupport;
import com.readnote.book.model.UserBook;
import com.readnote.book.service.UserBookService;

public class UserBookManageAction extends AppBaseActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1179031234511250745L;
	
	private Long[] ids;//数据更新主键集合
	private UserBook userBook;

	
	private UserBookService userBookService;
	
	/***
	 * 查看 userBook list
	 */
	public String index(){
		page = userBookService.getPage(getQuery(), page);
		return INDEX;
	}
	
	/***
	 * 查看 userBook list
	 */
	public String query(){
		page = userBookService.getPage(getQuery(), page);
		return INDEX;
	}
	
	/**
	 * 进入userBook更新页面
	 */
	public String input(){
		if(ids!=null && ids.length!=0)
			userBook = userBookService.get(ids[0]);
		return INPUT;
	}
	
	/**
	 * 保存（新建\更新）
	 * @methodDescribe 
	 * @return
	 * @author xianghua.hu
	 * @date 2012-5-15
	 */
	public String save(){
		if(userBook==null || userBook.isNullRow()){
			userBookService.save(userBook);
		}else{
			UserBook _userBook = userBookService.get( userBook.getId() );
			
			userBookService.update(_userBook);
		}
		return SUCCESS;
	}

	public Long[] getIds() {
		return ids;
	}

	public void setIds(Long[] ids) {
		this.ids = ids;
	}

	public UserBook getUserBook() {
		return userBook;
	}

	public void setUserBook(UserBook userBook) {
		this.userBook = userBook;
	}

	public UserBookService getUserBookService() {
		return userBookService;
	}

	public void setUserBookService(UserBookService userBookService) {
		this.userBookService = userBookService;
	}
	
	

	
}
